import { createRouter, createWebHashHistory } from 'vue-router'
import LayoutView from '@/LayoutView.vue'

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path:"/",
      redirect:"/home"
    },
    {
      path: "/",
      name: "layout",
      component: LayoutView,
      children: [
        {
          path: "/home",
          name: "home",
          component: () => import("@/views/HomeView.vue")
        },
        {
          path: "/work-life",
          name: "work",
          component: () => import("@/views/WorkLife.vue")
        },
        {
          path: "/study-more",
          name: "study",
          component: () => import("@/views/StudyMore.vue")
        },
        {
          path: "/hobby-part",
          name: "hobby",
          component: () => import("@/views/HobbyPart.vue")
        },
        {
          path:"/concat",
          name:"concat",
          component: ()=> import("@/views/ConcatView.vue")
        }
      ]
    },
    {
      path:"/message",
      name:"message",
      component: ()=> import("@/views/MessageView.vue")
    }
    ,
    {
      path: "/login",
      name: "login",
      component: () => import("@/views/LoginView.vue")
    },
    {
      path: "/register",
      name: "register",
      component: () => import("@/views/RegisterView.vue")
    },
    {
      path: "/user",
      name: "user",
      component: () => import("@/views/UserView.vue")
    },
    {
      path: "/detail",
      name: "detail",
      component: () => import("@/views/DetailView.vue")
    },
    {
      path: "/search",
      name: "search",
      component: () => import("@/views/SearchView.vue")
    },
    {
      // path:"*",// 报错
      path:"/:pathMatch(.*)*",// 此处的路由用于检索不存在的URL
      name:"error",
      component:()=> import("@/views/ErrorView.vue")
    }
  ],
})

export default router
